package com.inspsys.video.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.inspsys.common.annotation.Log;
import com.inspsys.common.core.controller.BaseController;
import com.inspsys.common.core.domain.AjaxResult;
import com.inspsys.common.enums.BusinessType;
import com.inspsys.common.utils.poi.ExcelUtil;
import com.inspsys.video.domain.VideoArea;
import com.inspsys.video.service.IVideoAreaService;
import com.inspsys.common.core.page.TableDataInfo;

/**
 * 视频区域管理Controller
 * 
 * @author inspsys
 * @date 2025-02-13
 */
@RestController
@RequestMapping("/video/area")
public class VideoAreaController extends BaseController {
    @Autowired
    private IVideoAreaService videoAreaService;

    /**
     * 查询视频区域管理列表
     */
    // @PreAuthorize("@ss.hasPermi('system:area:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoArea videoArea) {
        startPage();
        List<VideoArea> list = videoAreaService.selectVideoAreaList(videoArea);
        return getDataTable(list);
    }

    /**
     * 导出视频区域管理列表
     */
    // @PreAuthorize("@ss.hasPermi('system:area:export')")
    @Log(title = "视频区域管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoArea videoArea) {
        List<VideoArea> list = videoAreaService.selectVideoAreaList(videoArea);
        ExcelUtil<VideoArea> util = new ExcelUtil<VideoArea>(VideoArea.class);
        util.exportExcel(response, list, "视频区域管理数据");
    }

    /**
     * 获取视频区域管理详细信息
     */
    // @PreAuthorize("@ss.hasPermi('system:area:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(videoAreaService.selectVideoAreaById(id));
    }

    /**
     * 新增视频区域管理
     */
    // @PreAuthorize("@ss.hasPermi('system:area:add')")
    @Log(title = "视频区域管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoArea videoArea) {
        return toAjax(videoAreaService.insertVideoArea(videoArea));
    }

    /**
     * 修改视频区域管理
     */
    // @PreAuthorize("@ss.hasPermi('system:area:edit')")
    @Log(title = "视频区域管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoArea videoArea) {
        return toAjax(videoAreaService.updateVideoArea(videoArea));
    }

    /**
     * 删除视频区域管理
     */
    // @PreAuthorize("@ss.hasPermi('system:area:remove')")
    @Log(title = "视频区域管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(videoAreaService.deleteVideoAreaByIds(ids));
    }

    /**
     * 查询视频区域树
     */
    @GetMapping("/treeArea")
    public AjaxResult treeArea(VideoArea videoArea) {
        return success(videoAreaService.selectVideoAreaTree(videoArea));
    }
}
